# Maintainer: Daniel Isenmann <daniel [at] archlinux.org>
# Contributor: dorphell <dorphell@gmx.net>

pkgname=gc
pkgver=7.6.8
pkgrel=1
pkgdesc="A garbage collector for C and C++"
arch=('x86_64')
url="http://www.hboehm.info/gc/"
license=('GPL')
depends=('gcc-libs' 'libatomic_ops')
source=(https://github.com/ivmai/bdwgc/releases/download/v${pkgver}/${pkgname}-${pkgver}.tar.gz)
sha512sums=('525e84e3de0575a76dc994f746fb60f829c850442b6e4dbec5482000a478bb63b9e8d5ac6ddf677a341312207e228eb64442fd7b177223b86efbb9cef3e74aec')

prepare() {
  cd ${pkgname}-${pkgver}
}

build() {
  cd ${pkgname}-${pkgver}
  ./configure --prefix=/usr --enable-cplusplus --disable-static
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make
}

check() {
  cd ${pkgname}-${pkgver}
  make check
}

package() {
  cd ${pkgname}-${pkgver}
  make DESTDIR="${pkgdir}" install
  sed 's|GC_MALLOC 1L|gc 3|g' doc/gc.man |
    install -Dm644 /dev/stdin "${pkgdir}/usr/share/man/man3/gc.3"
}
